<template>
<div>
    <div class="doctor_seacher">
            权限名称:<el-input v-model="search_name" placeholder="请输权限名" style="width: 180px"></el-input>
           
            <el-button type="primary" @click="searche" icon="el-icon-search" style="margin-left:20px">搜索</el-button>
        </div>
        <el-divider><i class="el-icon-s-promotion"></i></el-divider>
<el-table
    :data="tableData" 
    border 
    style="width: 100%" 
    max-height="400">
    :default-sort = "{prop: 'id', order: 'descending'}"
    >
    <el-table-column
        type="index">
    </el-table-column>
    <el-table-column
      prop="id"
      label="ID"
      sortable
      width="60">
    </el-table-column>
    <el-table-column
      prop="name"
      label="权限名称"
      width="200">
    </el-table-column>
    <el-table-column
      prop="sign"
      label="标志"
      width="200">
    </el-table-column>
    <el-table-column
        prop="link"
        label="链接"
        width="200">
    </el-table-column>
    <el-table-column
        label="状态"
        >
        <template slot-scope="scope">
        <i class="el-icon-s-opportunity"></i>
        <span style="margin-left: 10px">{{ scope.row.status=='y'?'可用':'禁用' }}</span>
      </template>
        
    </el-table-column>
  </el-table>
  <div class="block">
   
                <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[2, 4, 6, 8]"
                    :page-size="4"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="totals">
                </el-pagination>
    </div>
</div>
</template>
<script>
const axios = require("axios");
  export default {
    data() {
      return {
        tableData: [],
        search_name: "",
        currentPage: 1,
        pagesize:4,
        totals:0,
      }
    },
    methods: {
        handleSizeChange(val) {
                this.pagesize=val;
                this.searche();
            },
            handleCurrentChange(val) {
                this.currentPage=val;
                this.searche();
        
            },
      searche(){
          axios.get("http://192.168.6.189:8080/hpl-perm/list?currentPage="
            +this.currentPage+"&pagesize="+this.pagesize+"&name="+this.search_name).then((r) => {
                if(r.data.code == 200){
                     this.tableData = r.data.data.records;
                        this.totals= r.data.data.total;
                }else if(r.data.code === 403){
                                        this.$notify({
                                            title: '警告',
                                            message: r.data.msg,
                                            type: 'warning'
                                            }); 
                                    }else if(r.data.code === 500){
                                        this.$notify({
                                            title: '警告',
                                            message: r.data.msg,
                                            type: 'warning'
                                            }); 
                                    }else{
                                this.$notify({
                                    title: '警告',
                                    message: '系统繁忙！',
                                    type: 'warning'
                                    }); 
                            } 
            })
      }
    },
    mounted(){
            this.searche();
    }

  }
</script>